/*Please enter your email.';
} else{
$email = trim($_POST["email"]);
}
// Check if password is empty
if (empty(trim($_POST['password']))){
$password_err = '
Please enter your password.';
} else {
$password = trim($_POST['password']);
}
// Validate credentials
if(empty($email_err) && empty($password_err)){
$sql = "SELECT email, password, accountid, verification FROM account WHERE email = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $email);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Store result
mysqli_stmt_store_result($stmt);
// Check if username exists, if yes then verify password
if(mysqli_stmt_num_rows($stmt) == 1){
// Bind result variables
mysqli_stmt_bind_result($stmt, $email, $hashed_password, $id, $verification);
if(mysqli_stmt_fetch($stmt)){
if(password_verify($password, $hashed_password)){
if($verification ==1){
/* Password is correct, so start a new session and save the username to the session */
/*session_start();
$_SESSION['email'] = $email;
$_SESSION['id'] = $id;
$time = time();
$insert_log_time = "REPLACE INTO userlog (id, logintime) VALUES ('$id',NOW())";
if (mysqli_query($link, $insert_log_time)) {
header("location: blog.php");
} else{
echo "SQL Error ";
echo mysqli_error($link);
}
}else{
$verification_err = 'Please verify email';
}
} else{
$password_err = "
The password you entered was not valid. $password, $hashed_password, $email";
}
}else {
echo "error with DB";
}
} else{
$email_err = '
No account found with that email.';
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
mysqli_stmt_close($stmt);
}
mysqli_close($link);
}
?>*/
Copyright © 2018 PetNet. All rights reserved.